package com.txh.blog.service.impl;

import com.txh.blog.mapper.ResmeMapper;
import com.txh.blog.model.Resme;
import com.txh.blog.service.ResMeservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResMeServiceImpl implements ResMeservice {
    @Autowired
    private ResmeMapper resmeMapper;
    @Override
    public Resme resMes() {
        List<Resme> list = resmeMapper.selectAll();
        if (list.size() ==0){
            return null;
        }else{
            return list.get(0);
        }
    }

    @Override
    public void save(Resme resme) {
            //id为空则是新增
        if(resme.getId() == null){
             resmeMapper.insert(resme);
        }else{
            update(resme);
        }

    }

    @Override
    public void update(Resme resme) {
        resmeMapper.updateByPrimaryKey(resme);
    }

    @Override
    public Resme getMeInfo() {
        List<Resme> resmes = resmeMapper.selectAll();
        Resme resme=null;
        if (resmes.size() >0){
            resme=resmes.get(0);
        }
        return resme;
    }
}
